import React, { PropTypes } from 'react';
import { Button, Form, Select, Input } from 'antd';
import { selectOptions } from 'src/utils/transform';
import FormHandle from 'components/decorator/formHandle';
import FormModal from 'components/decorator/formModal';
import { systemConstants } from 'src/utils/constants';

const Option = Select.Option;
const FormItem = Form.Item;

class DetailForm extends React.Component {

  render() {

    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 7 },
      wrapperCol: { span: 14 },
    };

    // debugger;
    const entity = { ...this.props.entity };

    return (
      <Form>
        <FormItem
          {...formItemLayout}
          label="编码"
          required={true}
        >
          {
            getFieldDecorator('entity.projectCode', {
              initialValue: entity ? entity.projectCode : '',
            })(
              <Input placeholder="" />,
            )
          }
        </FormItem>
        <div className="form-br" />
        <FormItem
          {...formItemLayout}
          label="名称"
          required={true}
        >
          {
            getFieldDecorator('entity.projectName', {
              initialValue: entity ? entity.projectName : '',
            })(
              <Input placeholder="" />,
            )
          }
        </FormItem>
        <div className="form-br" />
        <FormItem
          {...formItemLayout}
          label="状态"
          required={true}
        >
          {
            getFieldDecorator('entity.status', {
              initialValue: entity.status ? '' + entity.status : '1',
            })(
              <Select style={{ width: '150px' }}>
                { selectOptions(systemConstants.appStatus) }
              </Select>,
            )
          }
        </FormItem>
        <div className="form-br" />
        <FormItem
          {...formItemLayout}
          label="描述"
          required={true}
        >
          {
            getFieldDecorator('entity.introduction', {
              initialValue: entity ? entity.introduction : '',
            })(
              <Input type="textarea" rows={4}/>
            )
          }
        </FormItem>
      </Form>
    );
  }
}
export default Form.create({})(FormModal(DetailForm));
